<?
/*******************************************************************************************/
/*   CLASE BASE DE LOS MODULOS: Modulo                                                     */
/*******************************************************************************************/
class Modulo
	{
	// Propiedades de Configuracion del Modulo
		var $cPath;
		var $cPathTemplates;
		var $cPathRpt;
		var $cUrl;
		var $cUrlCss;
		var $cUrlJS;
		var $cUrlImages;
		var $cPathConf;
		var $cModule;
	// Propiedades de Configuracion del Entorno (index.php)
		var $cBodyProperties;
		var $cTitle;
		var $cAuthor;
		var $cIcon;
		var $cKeywords;
		var $cDescription;
		var $cUrlBack;
		var $cCloseScript;
	// Propiedades del Entorno
		var $cLanguage;
		var $nOutputType = 'html';
	// Propiedades de la Accion Actual
		var $cAction;
		var $nTask;
		var $nMode;
	// Variables Internas
		var $cHeadFiles = "";						// string que contactena arhivos php para el head
		var $cStyleSheet = "";		// string que contactena las hojas de estilo
		var $cScript= "";			// string que contactena los scripts 
		var $cTemplateHead = "head_inc.php";// Template del Head
		var $cTemplateBody = "body_inc.php";// Template del Body
		var $cTemplateFoot = "foot_inc.php";// Template del Foot
	// Objetos
		var $oDatabase;
		var $oUserSession;
		var $cMenuFile = '';
		var $cTarget;
		var $cSubModule;
		
	function getMenuMatrix(  )
		{
			$aMenu = array();
			if ( $this->cMenuFile != false && file_exists( $this->cMenuFile ) )
			{
				include_once( $this->cMenuFile );
			}
			return $aMenu;
		}
	// Devuelve V o F si el usuario tiene permiso de acceso a una accion.
	function isAllowed( $cAction )
		{
			return true;
		}
	// Si $cAction es un String => es un Archivo que esta dentro de su estructura de directorio
	function loadAction ( $cAction, $nTask = 1, $cRefresh = '' )
		{
			return true;
		}
	function load()
		{
		}
	function getUrlImages()
		{
			return $this->cUrlImages;
		}
	function getUrlJS()
		{
			return $this->cUrlJS;
		}
	function getRoles()
		{

		}
	function show()
		{
		}
	function refresh( $cClass , $cMethod = '' )
		{
		}

	function makeAction ( $cValor, $cAction , $cParametros = '', $ncModo = '', $cAccessKey = '' , $cTarget = '')
		{
		}
	function getActionArray( $cAction  )
		{
		}
	function getActionForm( $cAction = '', $nTask = '')
		{
			if ( $cAction == '' ) $cAction = $this->cAction;
			if ( $nTask == '' ) $nTask = $this->nTask + 1;
			// Arma la Url y la devuelve
			$cUrl  = '?' . PARAM_MODULE . '=' . $this->cModule . '&amp;' . PARAM_ACTION . '=' . $cAction . '&amp;' . PARAM_TASK . '=' . $nTask. '&amp;' . PARAM_MODE . '=' . $this->nMode;
			return $cUrl ;
		}

	function doc()
		{
		}
	function info()
		{
			echo phpinfo();
			exit();
		}

	function getPath()
		{
			return $this->cPath;
		}
	function url()
		{
			return $this->cUrl;
		}
	function &loadClass ( $cClass )
		{
		}
	function setTarget ( $cTarget )
		{
			$this->cTarget = $cTarget;
		}
	function getTarget ()
		{
			return $this->cTarget;
		}
	function getThisUrl ($bSendPostAsGet)
	{
		if ( FRAMEWORK_AJAX && $this->cUrlBack )
		{
			$cUrl = $this->cUrlBack;
		} else
		{
			$cUrl = getThisUrl($bSendPostAsGet);
		}
		$cUrl .= '&amp;' . PARAM_SUBMODULE . '=' . $this->cSubModule;
		return replaceString( PARAM_MODE, $this->nMode, $cUrl);
	}
	function getBack( $nMode = '')
	{
		if ( $nMode== '') $nMode = $this->nMode;
		return $_SESSION['back_'. $this->nMode] ;
	}
	function setBack ( $cUrl = '', $cTarget = '' )
		{
			if ( $cTarget = '' ) $cTarget = $this->cTarget;
			if ( $cUrl == '' ) $cUrl  = $this->getThisUrl ();
			$_SESSION['back_'. $this->nMode] = $cUrl;
		}
	function setRedirectUrl ( $cUrl ) {
		$this->cUrlBack = $cUrl ;
	}
	function setRedirect ( $cAction, $cParameters = '', $bSobreEscribe = true   )
	{
		if ( $bSobreEscribe == false && $this->cUrlBack ) return false;
		switch( $cAction )
		{
			case ACTION_NONE:
				$cUrl = '';
				break;
			case ACTION_NEXT:
				$cUrl = '?' . PARAM_MODULE . '=' . $this->cModule . '&amp;' . PARAM_ACTION . '=' . $this->cAction. '&amp;' . PARAM_REFRESH . '=action&amp;' . PARAM_TASK . '=' . ( $this->nTask + 1 );
				if ( $cParameters ) $cUrl .= "&amp;" . $cParameters;
				break;
			case ACTION_BACK:
				if ( FRAMEWORK_AJAX )
				{
					$cUrl = ACTION_BACK;
				} else
				{
					$cUrl = $_SESSION['back_'. $this->nMode];
					if ( $cUrl  =='') $this->cCloseScript ='<script>window.history.go(-1);</script>';
					$_SESSION['back_'. $this->nMode] = '';
				}
			break;
			default:
				$cUrl = '?' . PARAM_MODULE . '=' . $this->cModule . '&' . PARAM_ACTION . '=' . $cAction . '&' . PARAM_REFRESH . '=action';
				if ( $cParameters ) $cUrl .= "&" . $cParameters;
			break;
		}
		$this->cUrlBack = $cUrl ;
	}
	function redirect()
		{
			if ( $this->cUrlBack || $this->cCloseScript )
			{
				switch ( $this->nMode  )
				{
					case POPUP:
					case POPUP_CON_ACTUALIZACION:
						if ( $this->cCloseScript )
							echo $this->cCloseScript;
						else
							echo "<script type='text/javascript'>window.close();</script>";
						exit();
					break;
					case SIN_VENTANA:
						// Redirect en modo refresh
						if ( FRAMEWORK_AJAX && $this->cUrlBack == ACTION_BACK  && isMessage()  )
						{
							echo "[mensajes]" . showMessage() . "[/mensajes]" ;
						}
						break;
					case DIV_POPUP:
					case IFRAME:
					case VENTANA_SECUNDARIA:
					case VENTANA_PRINCIPAL:
						// Redirect en modo refresh
						if ( FRAMEWORK_AJAX )
						{
							if ( $this->cUrlBack == ACTION_BACK  )
							{
								if ( isMessage()  )
								{
									//echo "[javascript] " . $this->cTarget . ".setAttribute( 'url',  '" . $this->cUrlBack  . "' ); [/javascript]";
									echo "[mensajes]" . showMessage() . "[/mensajes]" ;
									if ( $this->cTarget  == 'body_main' ) exit();
								}
								echo "[javascript] refreshTarget ( \"" . $this->cTarget  ."\" ); [/javascript]";
								exit();
							} else
							{
								// Si esta en modo refresh => hace el redirect por Javascript
								global $aParameter;
								if ( $aParameter[PARAM_REFRESH] )
								{
									$cUrl = str_replace( "&amp;", "&", $this->cUrlBack);
									echo "[javascript] send( \"". $cUrl . "\", refreshElement, \"" . $this->cTarget  ."\", true, false); [/javascript]";
								}
								
								/*
								global $aParameter;
								$aParameter = array();
								// Arma un Array con el QueryString de la Accion del Redirect
								$cQueryString = substr( $this->cUrlBack , strpos( $this->cUrlBack , '?' ) + 1 );
								$aItems = split( "&amp;", str_replace('%','',$cQueryString));
								foreach( $aItems as $cItem )
								{
									$nPos = strpos($cItem, '=');
									if ( !($nPos===false) ) $aParameter[ substr($cItem,0,$nPos) ] = substr($cItem,$nPos+1);
								}
								$cModule  = $aParameter[PARAM_MODULE];
								$cAction  = $aParameter[PARAM_ACTION];
								$nTask		= $aParameter[PARAM_TASK];
								// Si es el mismo modulo => carga la accion
								if ( $cModule && $cModule != $this->cModule )
								{
									$oModule =& loadModule( $cModule  );
									$oModule->loadAction( $cAction , $nTask );
									$oModule->load();
								} elseif ( $cAction  )
								{
									$this->loadAction( $cAction , $nTask );
									$this->load();
								}
								*/
							}
						} else
						{
							if ( $this->cUrlBack ) 
							{
								saveMessage() ;
								echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"";
								echo "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
								echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"es\" lang=\"es\">";
								echo "<head>";
								echo "<meta HTTP-EQUIV=Refresh CONTENT=\"0; url=" . $this->cUrlBack . "\"/>";
								echo "</head>";
								$_SESSION['back_'. $this->nMode] = '';
								flush();
							} else
							{
								echo "<script>window.history.go(-1);</script>";
							}
							exit();
						}
					break;
				}
			} else
			{
				if ( isMessage() && FRAMEWORK_AJAX  )
				{
					echo "[mensajes]" . showMessage() . "[/mensajes]" ;
					cleanMessage();
					exit();
				}
			}
		}
	function showMessages($bRefresh = false)
		{
			//$bRefresh = ( $this->cTarget == 'body_main' ) ? false: true;
			if ( $bRefresh ) echo "[mensajes]";
			else			echo "<div id='mensajes'>";
			if ( isMessage() )
			{
				retrieveMessage();
				if ( isMessage() )
				{
					echo showMessage() ;
					cleanMessage();
				}
			}
			if ( $bRefresh ) echo "[/mensajes]";
			else			echo "</div>";
		}
	function setBodyProperties( $cBodyProperties )
		{
			$this->cBodyProperties = $cBodyProperties;
		}
	function addBodyProperties( $cBodyProperties )
		{
			$this->cBodyProperties .= $cBodyProperties;
		}
	function getUrl()
		{
			return $this->cUrl;
		}
	function data()
		{
		}
	function export ()
		{
		}
	function loadLibrary ( $cLibrary )
		{
			require_once( $this->getPath() . "/$cLibrary/$cLibrary" . "_ini.php" );
		}
	function Modulo( $cModule )
		{
			global $aParameter;
			$this->cModule = $cModule;
			if ( array_key_exists( 'back_1', $_SESSION) ) 
			{	
				$this->cUrlBack = $_SESSION['back_1'];
				$_SESSION['back_1'] = '';
			}
			$nMode = array_key_exists( PARAM_MODE, $aParameter ) ? $aParameter[PARAM_MODE] : VENTANA_PRINCIPAL;
			$this->setMode( $nMode );
			if ( array_key_exists( PARAM_TARGET, $aParameter )  )
			{
				$this->cTarget = $aParameter[PARAM_TARGET] ;
			} else
			{
				$this->cTarget = ( $nMode  == POPUP )  ? "popup": "body_main" ;
			}

		}
	function setCloseScript( $cJavaScript )
		{
			$this->cCloseScript = $cJavaScript;
		}
	function getAction ()
		{
			return $this->cAction;
		}
	function setTemplateHead ( $cTemplateHead )
		{
			$this->cTemplateHead = $cTemplateHead;
		}
	function getTemplateHead ()
		{
			return $this->cTemplateHead;
		}
	function getTemplatesArray()
	{
		$aData = array();
		$fd = opendir( $this->cPathTemplates );
		// Loop por cada archivo
		while ( $cArchivo = readdir($fd) )
		{
			$cArchivoActual = $this->cPathTemplates . "/" . $cArchivo;
			// Si es un archivo
			if ( filetype($cArchivoActual ) == 'file' )
			{
				list ( $cNombre, $cExtension ) = explode( ".", $cArchivo );
				if ( substr($cNombre, -3, 1 ) != '_'   )
					$aData[] =  $cNombre;
				elseif ( substr($cNombre, -3 ) == '_00'   )
					$aData[] =   substr($cNombre, 0, -3 );
			}
		}
		closedir($fd);
		return $aData;
	}
	function loadTemplatePage( $cTemplate = '', $cTemplateId ='', $cParametros= '', $nModo = '' )
	{
		if ( $cTemplate == '') $cTemplate = $this->cAction ;
		if ( $cTemplateId == '' ) $cTemplateId = $cTemplate;
		if ( file_exists ( $this->cPathTemplates . '/' . $cTemplate . "_00.php")  )
		{
			$aParametros = stringParametersToArray($cParametros);
			extract($aParametros);
			include( $this->cPathTemplates . '/' . $cTemplate . "_00.php" );	
			if ( !$this->aDatos[$cTemplateId][aModos] ) 
				$this->aDatos[$cTemplateId][aModos] = 1;
			else
			{
				$cThisUrl  = $this->aDatos[$cTemplateId][cThisUrl];
				if ( $this->aDatos[$cTemplateId][aSubModos] ) $cThisUrl .= "&amp;aSubModos=".$aDatos[$cTemplateId][aSubModos];
				if ( $aModos > 10 )
				{
					for ( $i = 0; $i < strlen($aModos); $i++ )
						$this->aDatos[$cTemplateId][aMenu][] = array(  1, trim(mostrar_termino( 'LBL_'.$cTemplate.'_0'.$aModos[$i] )) , $cThisUrl ."&amp;tr=" . $this->getTarget() . "&amp;pag=".$aModos[$i] ); 
				}
			}
		}
		if ( $nModo != '') $this->aDatos[$cTemplateId][aModos] = $nModo ;
	}
	function showTemplatePage($cTemplate ='', $cTemplateId ='', $cParametros = '', $nModo = '')
	{
		if ( $cTemplate == '') $cTemplate = $this->cAction ;
		if ( $cTemplateId == '' ) $cTemplateId = $cTemplate;
		$aModos = $this->aDatos[$cTemplateId][aModos];
		if ( $aModos )
		{
			$rf = getParam(rf);
			$pag = $nModo  ? $nModo : getParam( 'pag', substr(trim($aModos), 0, 1) ); 	
			if ($rf!='action')
			{
				echo "<div id='" . $cTemplate ."'>";
				include( $this->cPathTemplates . '/' .  $cTemplate . "_0" . $pag . ".php" );
				echo "</div>";
			} else
				include( $this->cPathTemplates . '/' .  $cTemplate . "_0" . $pag . ".php" );
		} else
		{
			include( $this->cPathTemplates . '/' .  $cTemplate . '.php' );	
		}
	}
	function getHead()
		{
			if ( $this->cTemplateHead  )
			{
				if ( file_exists( $this->cTemplateHead) )
					require( $this->cTemplateHead );
				else
				{
					$oModBase =& loadModule('base');
					if ( file_exists( $oModBase->cPathTemplates . "/" . $this->cTemplateHead ) )
					{
						require( $oModBase->cPathTemplates . "/" . $this->cTemplateHead );
					}
				}
			}
		}
	function setTemplateFoot ( $cTemplateFoot )
		{
			$this->cTemplateFoot = $cTemplateFoot;
		}
	function getTemplateFoot ()
		{
			return $this->cTemplateFoot;
		}
	function getFoot()
		{
			if ( $this->cTemplateFoot )
			{
				if ( file_exists( $this->cTemplateFoot) )
					require( $this->cTemplateFoot );
				else
				{
					$oModBase =& loadModule('base');
					if ( file_exists( $oModBase->cPathTemplates . "/" . $this->cTemplateFoot ) )
					{
						require( $oModBase->cPathTemplates . "/" . $this->cTemplateFoot );
					}
				}
			}
		}
	function setTemplateBody ( $cTemplateBody )
		{
			$this->cTemplateBody = $cTemplateBody;
		}
	function getTemplateBody ()
		{
			return $this->cTemplateBody;
		}
	function getBody()
		{
			if ( $this->cTemplateBody  )
			{
				if ( file_exists( $this->cTemplateBody) )
					require( $this->cTemplateBody );
				else
				{
					$oModBase =& loadModule('base');
					if ( file_exists( $oModBase->cPathTemplates . "/" . $this->cTemplateBody ) )
						require( $oModBase->cPathTemplates . "/" . $this->cTemplateBody );
				}
			}
		}
	function copy ( $oModuloCopy , $bData = true )
		{
			$this->nMode 				= $oModuloCopy->nMode;
			$this->cTitle 				= $oModuloCopy->cTitle;
			$this->cIcon 				= $oModuloCopy->cIcon;
			$this->cKeywords 		= $oModuloCopy->cKeywords;
			$this->cDescription		= $oModuloCopy->cDescription;
			$this->cScript 				.= $oModuloCopy->getScript();
			$this->cLanguage 				= $oModuloCopy->cLanguage;
			$this->cHeadFiles 				= $oModuloCopy->cHeadFiles;
			$this->cStyleSheet		= $oModuloCopy->getStyleSheet();
			$this->cTemplateHead = $oModuloCopy->cTemplateHead;
			$this->cTemplateBody 	= $oModuloCopy->cTemplateBody;
			$this->cTemplateFoot  = $oModuloCopy->cTemplateFoot;
			$this->cBodyProperties .= $oModuloCopy->cBodyProperties;
			$this->cUrl =  $oModuloCopy->cUrl;
			$this->cUrlCss = $oModuloCopy->cUrlCss;
			$this->cUrlJS = $oModuloCopy->cUrlJS;
			$this->cUrlImages = $oModuloCopy->cUrlImages;
			if ( $bData )
			{
				$this->oDatabase 		= $oModuloCopy->oDatabase;
				$this->oUserSession	=& $oModuloCopy->oUserSession;
			}
		}
	function getSubModule()
	{
		return $this->cSubModule ;
	}
	function setSubModule( $cSubDir )
		{
			// Verifica que Exista
			if( !file_exists ( $this->getPath() . "/" . $cSubDir ) )
			{
				die( "El submodulo " . $this->getPath() . "/" . $cSubDir  . " no existe " );
			}
			$this->cSubModule = $cSubDir;
		}
	function resetScript( )
		{
			$this->cScript = "";
		}
	function resetStyleSheet()
		{
			$this->cStyleSheet = "";
		}		
	function addScript( $cScript, $bFile = true , $cTypeScript = "javascript" )
		{
			if ( $bFile)
			{
				if ( substr($cScript, 0, 5) != 'http:' ) $cScript = '[UrlJS]/' . $cScript;
				$this->cScript = "<script type='text/$cTypeScript' src='$cScript'></script>" . $this->cScript;
			} else
			{
				$this->cScript = "<script type='text/$cTypeScript' >" . $cScript . "</script>" . $this->cScript;
			}
		}
	function getScript()
		{
			return str_replace( "[UrlJS]", $this->cUrlJS, $this->cScript );
		}
	function getHeadFiles()
		{
			if ( $this->cHeadFiles != '' )
				foreach ( explode( ',' , $this->cHeadFiles) as  $cArchivo )
					include_once($cArchivo);
		}
	function addHeadFile( $cArchivo )
		{
			$this->cHeadFiles .= $cArchivo . ', ' ;
		}
	function addStyleSheet ( $cSheet, $bFile = true  )
		{
			if ( $bFile)
			{
				$this->cStyleSheet .= "<link  rel='stylesheet'  href='[UrlCss]/$cSheet' type='text/css' />";
			} else
			{
				$this->cStyleSheet .= "<link  rel='stylesheet'  href='$cSheet' type='text/css' />";
			}
		}
	function getStyleSheet()
		{
			return str_replace( "[UrlCss]", $this->cUrlCss, $this->cStyleSheet );
		}
	function setTitle ($cTitle)
		{
			$this->cTitle = $cTitle;
		}
	function getTitle ()
		{
			return $this->cTitle;
		}
	function getAuthor ()
		{
			return $this->cAuthor;
		}
	function getKeywords ()
		{
			return $this->cKeywords;
		}
	function getModuleName()
		{
			return $this->cModule;
		}
	function setKeywords ($cKeywords)
		{
			$this->cKeywords = $cKeywords;
		}
	function setDescription ( $cDescription )
		{
			$this->cDescription = $cDescription;
		}
	function getDescription ()
		{
			return $this->cDescription;
		}
	function setIcon ($cIcon)
		{
			$this->cIcon = $cIcon;
		}
	function getIcon ()
		{
			return $this->cIcon;
		}
	function setLanguage( $cLanguage )
		{
			$this->cLanguage = $cLanguage;
		}
	function setMode( $nMode )
		{
			$this->nMode = $nMode;
		}
	function getMode()
		{
			return $this->nMode;
		}
	function setOutputType( $nOutputType)
		{
			$this->nOutputType = $nOutputType;
		}
	function getLanguage()
		{
			return $this->cLanguage;
		}
	function getOutputType( )
		{
			return $this->nOutputType;
		}
	/// makeLink($cUrl="",$cClass="",$cAlt="",$cImage="default.gif",$cTarget="")
	// $ncModo: 	1. En la misma ventana
	//          2. En otra ventana c/ refrescar padre
	//          3. En otra ventana s/ refrescar padre
	function makeLink( $cUrl="", $cClase="", $cNombre="", $cIcono="", $ncModo = VENTANA_PRINCIPAL, $ncTipoAccion = 3, $cTarget = '', $cAccessKey = '', $cPropiedades = "", $bReplaceTarget = true )
		{
			if ( $this->getOutputType() != 'html' ) return $cNombre ;

			if( $cUrl != "" )
			{
				if ( $cClase ) $cClase = " class='$cClase' ";
				if ( substr( $cUrl, 0 , 10 ) != 'javascript'  )
				{
					// Si esta en div_popup => sigue todo en el mismo modo
					if ( $this->getMode()  == DIV_POPUP ) $ncModo = DIV_POPUP ;
					/// Agrega el modo popup / nopopup
					$cUrl = replaceString( PARAM_MODE , $ncModo, $cUrl);
					switch( $ncModo )
					{
						case POPUP_CON_ACTUALIZACION:
						case POPUP:
								$cUrl = replaceString( PARAM_TARGET, "popup", $cUrl);
								$cUrl = replaceString( PARAM_REFRESH, "", $cUrl);
								$cUrl= "javascript: openWindow( \"$cUrl\" ,\"Popup\" ); return false;";
							break;
						case DIV_POPUP:
							if ( $cTarget == '') 	$cTarget = $this->cTarget;
							$cUrl = replaceString( PARAM_TARGET, "div_popup" . (getPopupNumber() + 1) . "_inside", $cUrl);
							if ( strpos($cUrl, PARAM_REFRESH . '=class') === false )  $cUrl = replaceString( PARAM_REFRESH, "action", $cUrl);
							$cUrl = "javascript: openPopup( \"$cUrl\" ,\"Popup\" ); return false;";
							break;
						case IFRAME:
							//if ( $cTarget == '') 	$cTarget = $this->cTarget;
							//$cUrl = "javascript: oF = document.getElementById( \"$cTarget\"); oF.src=\"$cUrl\"; return false;";
							//break;
						case VENTANA_SECUNDARIA:
						case VENTANA_PRINCIPAL:
						default:
						case '':
							if ( $cTarget == '') 	$cTarget = $this->cTarget;
							if ( $bReplaceTarget ) $cUrl = replaceString( PARAM_TARGET, $cTarget, $cUrl);
							if (  FRAMEWORK_AJAX == true )
							{
								if ( strpos($cUrl, PARAM_REFRESH . '=class') === false )  $cUrl = replaceString( PARAM_REFRESH, "action", $cUrl);
								$cUrl = "javascript: confirmOpenAjax( \"$cUrl\", ". $ncTipoAccion ." , " . $ncModo . ", \"" . $cTarget . "\", \"" . $cNombre . "\" ); return false; ";
							}
							break;
					}
				}
				if ( substr( $cUrl, 0 , 10 ) == 'javascript' ) $cHRef = "href='javascript:void(0);' onclick='$cUrl' ";
				else	$cHRef = "href='$cUrl'";

				if ( $cAccessKey != '' ) $cAccessKey = " accesskey='$cAccessKey' ";
				if ( $cIcono != "" )
				{
					return "<a $cPropiedades $cAccessKey $cHRef ><img style='width: 16px; height: 16px' $cClase src='$cIcono' alt='$cNombre' title='$cNombre' /></a>";
				} else
				{
					return "<a $cClase $cAccessKey $cPropiedades $cHRef>$cNombre</a>";
				}
			}
		}
	}

	function getPopupNumber()
		{
			global $aParameter;
			$cTarget = $aParameter[PARAM_TARGET] ;
			if ( substr($cTarget , 0, 9) == 'div_popup' )
			{
				return substr($cTarget , 9, 1);
			}
			return 0;
		}
?>